package com.zr.java8.pattern.state.impl;

import com.zr.java8.pattern.state.OrderContext;
import com.zr.java8.pattern.state.OrderState;

// 待支付状态
public class PendingState implements OrderState {
    @Override
    public void pay(OrderContext context) {
        // 待支付状态下可以执行支付，支付后切换到已支付状态
        System.out.println("订单支付成功！");
        context.setState(new PaidState()); // 状态切换
    }

    @Override
    public void ship(OrderContext context) {
        System.out.println("错误：订单未支付，无法发货！");
    }

    @Override
    public void complete(OrderContext context) {
        System.out.println("错误：订单未支付，无法完成！");
    }

    @Override
    public String getStateName() {
        return "待支付";
    }
}



